<template>
  <div class="wrap">
    <div class="surrounding-item">
      <div v-for="item in surrounding" :key="item.id">
        <img :src="'https://ss.lanqb.com/' + item.imgCover" alt="" />
        <h3>{{ item.merch.title }}</h3>
        <div class="avatarCon" @click="to">
          <div class="avatar">
            <img :src="'https://ss.lanqb.com/' + item.profile.avatar" alt="" />
            <span>{{ item.profile.nickname }}</span>
          </div>
          <div class="price">
            <p>￥{{ item.merch.sale_rmb_price }}</p>
            <button>前往购买</button>
          </div>
        </div>
        <div class="price"></div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "DachuActiveThree",

  data() {
    return {
      surrounding: [],
    };
  },

  methods: {
    to(){
      this.$router.push('/DachuThreeInfo')
    }
  },
  created() {
    fetch(
      "https://m.lanqb.com/api/daniu/interview?link=paging&type=merch&limit=12&page=1"
    )
      .then((res) => res.json())
      .then((data) => {
        this.surrounding = data.data;
        console.log(this.surrounding);
      });
  },
};
</script>

<style lang="scss" scoped>
* {
  margin: 0;
  padding: 0;
}
.wrap {
  padding:0 10px;
  background-color: #eee;
  height: calc(100vh - 200px);
  overflow-y: scroll; // 开启滚动
  .surrounding-item {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    div {
      width: 187px;
      margin-top: 10px;
      margin-right: 10px;
      
      > img {
        width: 187px;
        height: 187px;
      }
      h3 {
        font-weight: 500;
        font-size: 18px;
        margin: 5px 0;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
      }
    }
    .avatarCon {
      .avatar {
        display: flex;
        align-items: center;
        img {
          width: 19px;
          height: 19px;
          border-radius: 50%;
          padding-right: 10px;
        }
      }
      .price{
          display: flex;
          justify-content: space-between;
          align-items: center;
          p{
            color: #ff7879;
            font-weight: 500;
            font-size: 22px;
          }
        button{
          width: 77px;
          height: 26px;
          border-radius: 15px;
          color: #634b19;
    background-color: #edce8c;
    border: none;
        }
        }
    }
  }
}
</style>
